﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace MuseUI.ObservableData
{
    public class ObservableDataOption : INotifyPropertyChanged
    {
        public ObservableDataOption(string optionName, bool isShown, Color colour, bool isRecording)
        {
            _optionName = optionName;
            _isShown = isShown;
            _isRecording = isRecording;
            _seriesColour = colour;
        }

        private bool _isShown;
        private bool _isRecording;
        private string _optionName;
        private Color _seriesColour;

        public Color SeriesColour
        {
            get { return _seriesColour; }
        }

        public bool IsRecording
        {
            get { return _isRecording; }
            set { SetField(ref _isRecording, value, "IsRecording"); }
        }

        public bool IsShown
        {
            get { return _isShown; }
            set { SetField(ref _isShown, value, "IsShown"); }
        }
        public string OptionName
        {
            get { return _optionName; }
            set { SetField(ref _optionName, value, "OptionName"); }
        }


        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        protected bool SetField<T>(ref T field, T value, string propertyName)
        {
            if (EqualityComparer<T>.Default.Equals(field, value)) return false;
            field = value;
            NotifyPropertyChanged(propertyName);
            return true;
        }
    }
}
